/*
	File: data/scripts/scene_ui-sprites.nut
	Author: GameStart3d.com
*/

/*!
	@short	SceneUISprites
	@author	GameStart3d.com
*/
class	SceneUISprites
{
	texture 	=	0
	sprites		=	0
	ui			=	0
	phase		=	0.0

	function	OnSetup(scene)
	{
		print("SceneUISprites::OnSetup()")
		ui = SceneGetUI(scene)
		sprites = []
		local n, x, y, w, h
		x = 16
		y = 480 
		//	Test the line below with "data/assets/ui_popn_twinbee_pink_sprite.png"
		texture = ResourceFactoryLoadTexture(g_factory, "data/assets/ui_popn_twinbee_rainbow_bell_sprite.png")
		w = TextureGetWidth(texture)
		h = TextureGetHeight(texture)
		for(n = 0; n < 16; n++)
		{

			if (n == ((n / 2.0).tointeger() * 2))
				y = 480
			else
				y = 480 + (h * 2.0)

			sprites.append(UIAddSprite(ui, -1, texture, x, y, w, h))
			SpriteSetPivot(sprites[n], w * 0.5, h * 0.5)
			x += w * 1.25
		}

		local spr = UIAddSprite(ui, -1, texture, 640, 200, w, h)
		SpriteSetPivot(spr , w * 0.5, h * 0.5)
		SpriteSetScale(spr, 4, 4)

	}

	function	OnUpdate(scene)
	{
		local	dt_frame = 1.0 / 60.0
		phase += 90.0 * dt_frame

		foreach(idx, spr in sprites)
		{
			local	scale = (sin(Deg(phase + idx * 15.0)) + 2.0) * 0.5 + 0.5
			SpriteSetScale(spr, scale, scale)
		}
	}
}
